﻿using System;
using System.IO;

namespace SomeKit.Serialization
{
    public static partial class SerializationHelper
    {
        public static void SerializeToStream<T>(this T obj, Stream stream, Action<Stream, T> objectWriter)
        {
            objectWriter(stream, obj);
        }

        public static void SerializeAsXmlToStream<T>(this T obj, Stream stream)
        {
            obj.Serialize(WriteObjectAsXml<T>);
        }

        public static void SerializeAsJSonToStream<T>(this T obj, Stream stream)
        {
            obj.Serialize(WriteObjectAsJson<T>);
        }
    }
}
